package cn.outmaneuver.outman.demo.web.domain.response;
/**
 * Copyright 2023-2023 by DongYaoMing. All Rights Reserved.
 */

/**
 * StandardResult
 * <p> 标准结果实体类</p>
 *
 * @author DongYaoMing
 * @version 1.0
 * @date 2023/09/27
 */
public class StandardResult<T> {
    private Boolean success;
    private String code;
    private String message;
    private T data;

    public StandardResult() {
    }

    public StandardResult(String code, String message) {
        this.success = false;
        this.code = code;
        this.message = message;
    }

    public StandardResult(T data) {
        this.success = true;
        this.code = "000000";
        this.message = "成功！";
        this.data = data;
    }

    public static StandardResult success(String message) {
        StandardResult standardResult = new StandardResult();
        standardResult.setSuccess(true);
        standardResult.setCode("000000");
        standardResult.setMessage(message);
        return standardResult;
    }

    public static <T> StandardResult<T> success(T data) {
        return new StandardResult<>(data);
    }

    public static StandardResult fail(String code, String message) {
        return new StandardResult(code, message);
    }

    public Boolean isSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
